package com.shqcjd.preinstallmobile.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.preinstallmobile.R;
import com.shqcjd.preinstallmobile.model.pojo.IndexBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 横向专家列表
 * Created by sy on 2019/3/15.
 */

public class HorizontalExpertAdapter extends BaseQuickAdapter<IndexBean.ExpertBean, HorizontalExpertAdapter.ViewHolder> {

    public HorizontalExpertAdapter(@Nullable List<IndexBean.ExpertBean> data) {
        super(R.layout.item_horizontal_expert, data);
    }

    @Override
    protected void convert(HorizontalExpertAdapter.ViewHolder helper, IndexBean.ExpertBean item) {
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.ic_default_tx)    //加载成功之前占位图
                .error(R.mipmap.ic_default_tx)    //加载错误之后的错误图
//                .override(40, 40)    //指定图片的尺寸
                .centerCrop();//指定图片的缩放类型为centerCrop （等比例缩放图片，直到图片的宽高都
        Glide.with(mContext)
                .load(R.mipmap.ic_default_tx)
                .apply(options)
                .into(helper.civ_icon);
        helper.tv_name.setText(item.name);
        helper.tv_expert_info.setText(item.info);
        helper.tv_expert_type.setText(item.expert_type);
    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.civ_icon)
        CircleImageView civ_icon;
        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_expert_info)
        TextView tv_expert_info;
        @BindView(R.id.tv_expert_type)
        TextView tv_expert_type;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
